<?php

include 'DBconnect.php';

class DB {

    public $db;
    public $result;

    //function of insert_Customer 
    public function Insert_Person($Tablename, $Name, $Password, $Email, $Phone_Number) {

        $this->Tablename = $Tablename;
        $this->Name = $Name;
        $this->Password = $Password;
        $this->Email = $Email;
        $this->Phone_Number = $Phone_Number;
        $this->db = mysql_select_db('book_market') or die(mysql_error());

        //$order =  'insert into customer values("","'.$name.'","'.$password.'","'.$email.'",'.$age.')';

        $order = 'insert into ' . $Tablename . '(Customer_Id,Name,Password,Email,Phone_Number)  values(" ","' . $Name . '","' . $Password . '","' . $Email . '",' . $Phone_Number . ')';

        $this->result = mysql_query($order) or die(mysql_error());  //order executes
        if ($this->result) {

            //echo("<br><b> Registration has been done\n");
            return true;
        } else {

            echo("<br>Input data is fail");
        }
    }

    public function SelectPerson($User_Info) {
        $querysentence = 'SELECT ' . $User_Info[0] . ' FROM  ' . $User_Info[1] . ' WHERE ' . $User_Info[2] . ' = "' . $User_Info[3] . '" AND ' . $User_Info[4] . ' = "' . $User_Info[5] . '" ';
        $query = mysql_query($querysentence);
       //echo $querysentence;
        if (mysql_num_rows($query) > 0) {
            while ($result = mysql_fetch_assoc($query)) {
                $ansname = $result['Name'];
                $anspassword = $result['Password'];
            }
            $ans = array($ansname, $anspassword);
        return $ans;
        }else{
            return null;
        }
        
    }

}

?>
